home *** CD-ROM | disk | FTP | other *** search
- #include "stdafx.h"
-
- cAnimatable::cAnimatable(cProperties *_orig)
- : cDisplayable(_orig)
- {
- animation = 0;
- looped = FALSE;
- }
-
- cAnimatable::~cAnimatable()
- {
- animation->delete_list();
- }
-
- void cAnimatable::add_image_to_sequence(cImage *image)
- {
- if (animation == 0 && current_image_finished())
- set_image(image);
- else
- new cContainer<cImage> (&animation, image);
- }
-
- void cAnimatable::add_sequence(cAnimation &anim, int _looped)
- {
- cImage *i;
-
- looped = _looped;
- last = anim;
-
- for (i = anim.start_frame; i != 0 && i != anim.end_frame; i = (cImage *)i->next)
- add_image_to_sequence(i);
-
- add_image_to_sequence(i);
- }
-
- void cAnimatable::add_inverse_sequence(cAnimation &anim)
- {
- cImage *i;
-
- looped = FALSE;
- last = anim;
-
- for (i = anim.end_frame; i != 0 && i != anim.start_frame; i = (cImage *)i->prev)
- add_image_to_sequence(i);
-
- add_image_to_sequence(i);
- }
-
- void cAnimatable::add_first_in_sequence(cAnimation &anim)
- {
- looped = FALSE;
- last = anim;
-
- add_image_to_sequence(anim.start_frame);
- }
-
- void cAnimatable::add_last_in_sequence(cAnimation &anim)
- {
- looped = FALSE;
- last = anim;
-
- add_image_to_sequence(anim.end_frame);
- }
-
- void cAnimatable::add_sequence(char *anim, int looped)
- {
- cAnimation seq;
-
- orig->get_sequence(anim, seq);
- add_sequence(seq, looped);
- }
-
- void cAnimatable::add_inverse_sequence(char *anim)
- {
- cAnimation s;
-
- orig->get_sequence(anim, s);
- add_inverse_sequence(s);
- }
-
- void cAnimatable::add_last_in_sequence(char *anim)
- {
- cAnimation s;
-
- orig->get_sequence(anim, s);
- add_last_in_sequence(s);
- }
-
- void cAnimatable::add_first_in_sequence(char *anim)
- {
- cAnimation s;
-
- orig->get_sequence(anim, s);
- add_first_in_sequence(s);
- }
-
- int cAnimatable::control()
- {
- if (animation != 0 && current_image_finished())
- {
- // Next frame
-
- set_image(animation->contents);
- delete(animation);
-
- // Do looped animations
-
- if (animation == 0 && looped && last.start_frame != last.end_frame)
- add_sequence(last, TRUE);
- }
-
- return TRUE;
- }
-
-